package com.example.demo.controller;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.common.Result;
import com.example.demo.entity.Paper;
import com.example.demo.entity.PaperQuestion;
import com.example.demo.mapper.PaperMapper;
import com.example.demo.mapper.PaperQuestionMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * @descreption:
 * @author: xhr
 * @date: 2022/9/03
 */
@RestController
@RequestMapping("/paperquestion")
public class PaperQuestionController {
    @Resource
    PaperQuestionMapper paperquestionMapper;

    //增
    @PostMapping
    public Result<?> save(@RequestBody PaperQuestion paperquestion) {

        paperquestionMapper.insert(paperquestion);
        return Result.success();
    }
    // 改
//    @PutMapping
//    public Result<?> update(@RequestBody PaperQuestion paperquestion) {
//        paperquestionMapper.updateById(paperquestion);
//        return Result.success();
//    }
    // 删
    @DeleteMapping("/{id}")
    public Result<?> update(@PathVariable Long id) {
        paperquestionMapper.deleteById(id);
        return Result.success();
    }
    //查
//    @GetMapping
//    public Result<?> findPage(@RequestParam(defaultValue = "10") Integer pagesize,
//                              @RequestParam(defaultValue = "1") Integer pagenum,
//                              @RequestParam(defaultValue = "") String search) {
//        LambdaQueryWrapper<PaperQuestion> wrapper = Wrappers.<PaperQuestion>lambdaQuery();
//        if (StrUtil.isNotBlank(search)) {
//            wrapper.like(PaperQuestion::getName, search);
//        }
//        return Result.success(paperquestionMapper.selectPage(new Page<>(pagenum, pagesize), wrapper));
//    }
}
